package com.huawei.appgallery.foundation.ui.framework.widget.button;

import android.content.Context;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import o.cka;
import o.ckc;
import o.ckf;
import o.Logger;

public class ButtonFactory {
    private static Map<Class<? extends BaseDownloadButton>, Class<? extends ckc>> ˊ = new ConcurrentHashMap();
    private static ckf ˋ = null;

    public static ckc ˏ(Class<? extends BaseDownloadButton> cls, Context context) {
        Class cls2 = (Class) ˊ.get(cls);
        if (cls2 == null) {
            Logger.e("ButtonFactory", "delegate do not register.");
            return new cka(context);
        }
        try {
            return (ckc) cls2.getDeclaredConstructor(new Class[]{Context.class}).newInstance(new Object[]{context});
        } catch (Throwable e) {
            throw new ButtonConstructorException("create Delegate failed.", e);
        } catch (Throwable e2) {
            throw new ButtonConstructorException("create Delegate failed.", e2);
        } catch (Throwable e22) {
            throw new ButtonConstructorException("create Delegate failed.", e22);
        } catch (Throwable e222) {
            throw new ButtonConstructorException("create Delegate failed.", e222);
        }
    }

    public static void ˏ(Class<? extends BaseDownloadButton> cls, Class<? extends ckc> cls2) {
        ˊ.put(cls, cls2);
    }

    public static void ˎ(ckf o_ckf) {
        ˋ = o_ckf;
    }

    public static ckf ˋ() {
        return ˋ;
    }

    public static List<DownloadButton> ˊ() {
        return DownloadButton.ˊ;
    }
}
